package net.elib.controller;

import net.elib.entity.Book;
import net.elib.service.BookService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: ked
 * Date: 21.08.12
 * Time: 21:00
 * To change this template use File | Settings | File Templates.
 */
public class BookForm extends AbstractController {
    private BookService bookService;

    public void setBookService(BookService bookService) {
        this.bookService = bookService;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
        HttpServletResponse response) throws Exception {

        List<Book> books = this.bookService.listAll();

        return new ModelAndView("books", "books", books);
    }
}
